<template>
  <a-modal
    :visible="visible"
    :title="editId?'编辑数据字典':'新增数据字典'"
    okText='保存'
    :width="700"
    @cancel="() => { $emit('cancel') }"
    @ok="() => { $emit('create') }"
  >
    <a-form :form="form">
      <a-row>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="字典项编码"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-input v-decorator="['code',
            {
              rules: [{ required: true, message: '请输入字典项编码!' }],
            }]" :disabled="editId" />
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="字典项名称"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-input v-decorator="['name',
            {
              rules: [{ required: true, message: '请输入字典项名称!' }],
            }]"/>
          </a-form-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :md="12" :sm="24">
          <a-form-item label="类型编码" :labelCol="{span: 7,offset: 1}" :wrapperCol="{span: 15, offset: 1}">
            <a-input v-decorator="['typeCode',
            {
              rules: [{ required: true, message: '请输入字典类型编码!' }],
            }]" :disabled="editId" />
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item label="类型名称" :labelCol="{span: 7,offset: 1}" :wrapperCol="{span: 15, offset: 1}">
            <a-input v-decorator="['typeName',
            {
              rules: [{ required: true, message: '请输入字典类型名称!' }],
            }]" :disabled="editId" />
          </a-form-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :md="12" :sm="24">
          <a-form-item label="排序值" :labelCol="{span: 7,offset: 1}" :wrapperCol="{span: 15, offset: 1}">
            <a-input-number v-decorator="['order']"/>
          </a-form-item>
        </a-col>
        <!-- <a-col :md="12" :sm="24">
          <a-form-item label="是否编码" :labelCol="{span: 7,offset: 1}" :wrapperCol="{span: 15, offset: 1}">
            <a-input v-decorator="['sjbm']"/>
          </a-form-item>
        </a-col> -->
      </a-row>
      <a-form-item label="备注" :labelCol="{span: 2}" :wrapperCol="{span: 21, offset: 1}">
        <a-input type="textarea" v-decorator="['remark']" :autosize="{ minRows: 2, maxRows: 6 }" :disabled="editId" />
      </a-form-item>
    </a-form>
  </a-modal>
</template>

<script>
export default {
  props: ['visible','editId'],
  beforeCreate () {
    this.form = this.$form.createForm(this)
  }
}
</script>

<style>

</style>
